PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Operators

Operators are described in detail in Operations.

Table A-7 summarizes the operators AppleScript supports. The first column lists the operators. The second column shows the syntax for using the operators in expressions. The placeholders in the syntax descriptions correspond to AppleScript value classes, which are described briefly in Placeholders, and in more detail in Values and Constants

Synonyms are listed in groups. The table shows the syntax for the first operator, but operators that are synonyms follow the same syntax rules.

Table A-7   Operators  

Operator

Syntax

Arithmetic operators

* number * number
+ number + number
date
+ number
- number - number
date
- number
date
- date
÷
/
number ( ÷ | / ) number
^ number ^ number
div number div number
mod number mod number

Logical operators

and Boolean and Boolean
not not Boolean
or Boolean or Boolean

Containment operators

start[s] with
begin[s] with
list starts with list
string
starts with string
end[s] with list ends with list
string
ends with string
contains list contains list
record
contains record
string
contains string
does not contain
doesn't contain
list does not contain list
record
does not contain record
string
does not contain string
is in
is contained by
list is in list
record
is in record
string
is in string
is not in
is not contained by
isn't contained by
list is not in list
record
is not in record
string
is not in string

Comparison operators (equality and inequality)

=
equal
equals
equal to
is
is equal to
expression = expression

does not equal
doesn't equal
is not
is not equal [to]
isn't
isn't equal [to]
expression expression

Comparison operators (precedence)

<
comes before
is less than
is not greater than or equal [to]
isn't greater than or equal [to]
less than
date < date
integer
< integer
real
< real
string
< string
>
comes after
greater than
is greater than
is not less than or equal [to]
isn't less than or equal [to]
date > date
integer
> integer
real
> real
string
> string

<=
does not come after
doesn't come after
is less than or equal [to]
is not greater than
isn't greater than
less than or equal [to]
date date
integer
integer
real
real
string
string

>=
does not come before
doesn't come before
greater than or equal [to]
is greater than or equal [to]
is not less than
isn't less than
date date
integer
integer
real
real
string
string

Miscellaneous operators

& (concatenation) expression & expression
as expression as className
a reference to [a] ( ref [to] | reference to ) reference

Table A-8 shows the order in which AppleScript performs operations. The column labeled "Associativity" indicates the order in which AppleScript performs operations if there are two or more operations of the same precedence in an expression. The word "none" in the Associativity column indicates that you cannot have multiple consecutive occurrences of the operation in an expression. For example, the expression 3 = 3 = 3 is not legal because the associativity for the equal operator (=) is "none." The word "unary" indicates that the operator is a unary operator. To evaluate expressions with multiple unary operators of the same order, AppleScript applies the operator closest to the operand first, then applies the next closest operator, and so on. For example, the expression not not not true is evaluated as not (not (not true)).

Table A-8   Operator precedence 

Order

Operators

Associativity

Type of operator

1 ( ) Innermost to outermost Grouping
2 +
-
Unary Plus or minus sign for numbers
3 ^ Right to left Exponentiation
4 *
/
÷
div
mod
Left to right Multiplication and division
5 +
-
Left to right Addition and subtraction
6 & Left to right Concatenation
7 as Left to right Coercion
8 <

>
None Comparison
9 =
None Equality and inequality
10 not Unary Logical negation
11 and Left to right Logical for Boolean values
12 or Left to right Logical for Boolean values

© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)